<template>
    <div>
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="getStoreByCategory">
            <store-list :storeList="storeList"></store-list>
        </van-list>
    </div>
</template>

<script>
import store from '@/api/store'
import StoreList from './StoreList'

export default {
    components:{StoreList},
    data(){
        return{
            storeList: [],
            finished: false,
            loading: false,
        }
    },
    created(){
        
    },
    methods:{
        getStoreByCategory(){
            let categoryId = this.$route.params.id

            let longitude = this.$store.state.location.longitude
            let latitude = this.$store.state.location.latitude
            let data = {
                longitude,
                latitude
            }
            store.getStoreByCategory(categoryId, data)
            .then(res => {
                if(res.code == 200){
                    console.log(res)
                    this.storeList = res.data.storeList
                    this.loading = false
                    this.finished = true
                }
                else{
                    
                }
            })
        }
    }
}
</script>